package com.anzhen.interview;

import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;

/**
 * Created by zhenan on 2017/2/23.
 */
public class Collection {

    @Test
    public void testList() {
        ArrayList<String> list = new ArrayList<String>();
        list.add("1");
        list.add("2");
        list.add("3");
        list.add("4");
        Iterator<String> iterator = list.iterator();
        while (iterator.hasNext()) {
            if (iterator.next().equals("1")) {
                iterator.remove();
            }
        }
        System.out.println(Arrays.toString(list.toArray()));
    }
}
